package ask.speedy.basic;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("serial")
public class BasicNode implements Serializable {

	private String information;
	private String urlImage;
	private String answer;
	private BasicNode parent;
	private Map<String, BasicNode> childs;
	
	/**
	 * constructor
	 */
	public BasicNode() {
		this.setInformation(null);
		this.urlImage = null;
		this.answer = null;
		this.parent = null;
		this.childs = new HashMap<String, BasicNode>();
	}
	
	/**
	 * constructor
	 * @param information
	 * @param parent
	 * @param childs
	 */
	public BasicNode(String information, String urlImage, String answer, BasicNode parent, Map<String, BasicNode> childs) {
		this.setInformation(information);
		this.urlImage = urlImage;
		this.answer = answer;
		this.parent = parent;
		if (childs != null)
			this.childs = childs;
		else
			this.childs = new HashMap<String, BasicNode>();
	}

	/**
	 * @return the childs
	 */
	public Map<String, BasicNode> getChilds() {
		return childs;
	}

	/**
	 * @param childs the childs to set
	 */
	public void setChilds(Map<String, BasicNode> childs) {
		this.childs = childs;
	}
	
	/**
	 * add a child of BasicNode
	 * @param key key-map
	 * @param val child-basicnode
	 */
	public void addChild(String key, BasicNode val) {
		if (childs != null) {
			childs.put(key, val);
		} else {
			childs = new HashMap<String, BasicNode>();
			childs.put(key, val);
		}
	}

	/**
	 * @return the urlImage
	 */
	public String getUrlImage() {
		return urlImage;
	}

	/**
	 * @param urlImage the urlImage to set
	 */
	public void setUrlImage(String urlImage) {
		this.urlImage = urlImage;
	}

	/**
	 * @return the answer
	 */
	public String getAnswer() {
		return answer;
	}

	/**
	 * @param answer the answer to set
	 */
	public void setAnswer(String answer) {
		this.answer = answer;
	}

	/**
	 * @return the information
	 */
	public String getInformation() {
		return information;
	}

	/**
	 * @param information the information to set
	 */
	public void setInformation(String information) {
		this.information = information;
	}

	/**
	 * @return the parent
	 */
	public BasicNode getParent() {
		return parent;
	}

	/**
	 * @param parent the parent to set
	 */
	public void setParent(BasicNode parent) {
		this.parent = parent;
	}
	
	public BasicNode getChild(String key) {
		return this.childs.get(key);
	}
	
}
